require(['./config'], () => {
    require(['footer', 'service', 'jquery'], () => {
        class Index {
            constructor() {
                this.register()
            }
            register() {
                $('button').on('click',  ()=> {
                    // console.log($('.agree').prop('checked'))
                    if ($('.agree').prop('checked')) {
                        const userInfo = {
                            name: $('#user').val(),
                            pwd: $('.code').val()
                        }
                        let userList = localStorage.getItem('userList')
                        if (userList) {
                            userList = JSON.parse(userList)
                            userList.push(userInfo)
                            localStorage.setItem('userList', JSON.stringify(userList))
                        } else {
                            localStorage.setItem('userList', JSON.stringify([userInfo]))
                        }
                        alert('注册成功，即将跳转')
                        location.href = '/html/login.html'
                    } else {
                        alert('请点击同意')
                    }
                })
            }
        }
        new Index()
    })
})